/*
 * TMap Designer - A Thematic Map design software
 * Copyright (C) 2006 World Health Organization
 * http://www.who.int
 *
 * This library is free software; you can redistribute it and/or
 * modify it under the terms of the GNU Lesser General Public
 * License as published by the Free Software Foundation; either
 * version 2.1 of the License, or (at your option) any later version.
 *
 * This library is distributed in the hope that it will be useful,
 * but WITHOUT ANY WARRANTY; without even the implied warranty of
 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
 * Lesser General Public License for more details.
 *
 * You should have received a copy of the GNU Lesser General Public
 * License along with this library; if not, write to the Free Software
 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301  USA
 */
package who.tmap.toolkit.shape.impl;

import who.tmap.bo.BizObjects;
import who.tmap.bo.TextStyle;
import who.tmap.bo.impl.BizObjectFactory;
import who.tmap.common.TMapException;
import who.tmap.toolkit.shape.MapShape;
import who.tmap.toolkit.shape.MapShapes;
import who.tmap.toolkit.shape.annotation.LabelsListShape;
import who.tmap.toolkit.shape.annotation.impl.BackgroundImageShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.CrossShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.EllipseShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.ImageShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.LabelShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.LabelsListShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.LegendShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.LineShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.RectangleShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.TextShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.TitleShapeImpl;
import who.tmap.toolkit.shape.annotation.impl.TriangleShapeImpl;
import who.tmap.toolkit.shape.cdpointsymbol.impl.CircleCDPointSymbolImpl;
import who.tmap.toolkit.shape.cdpointsymbol.impl.CrossCDPointSymbolImpl;
import who.tmap.toolkit.shape.cdpointsymbol.impl.ImageCDPointSymbolImpl;
import who.tmap.toolkit.shape.cdpointsymbol.impl.SquareCDPointSymbolImpl;
import who.tmap.toolkit.shape.cdpointsymbol.impl.TriangleCDPointSymbolImpl;

/**
 * @author stl
 *
 * To change the template for this generated type comment go to
 * Window&gt;Preferences&gt;Java&gt;Code Generation&gt;Code and Comments
 */
public class MapShapeFactory implements MapShapes {
	
	private static final MapShapeFactory instance =new MapShapeFactory();
	
	protected MapShapeFactory() {
	}
	
	public static final MapShapeFactory getInstance() {
		return instance;
	}
	
	public MapShape getGraphic( int graphicId ) throws TMapException {
		MapShape graphic =null;
		
		switch( graphicId ) {
			case LINE:
				graphic =new LineShapeImpl();
				break;
				
			case POLYGON:
				graphic =new PolygonShapeImpl();
				break;
				
			case TEXT:
				graphic =new TextShapeImpl();
				break;
				
			case IMAGE:
			    graphic =new ImageShapeImpl();
			    break;
				
			case RECTANGLE:
				graphic =new RectangleShapeImpl();
				break;
				
			case LABEL:
				graphic =new LabelShapeImpl();
				break;
				
			case TITLE:
				graphic =new TitleShapeImpl();
				break;	
				
			case LEGEND:
				graphic =new LegendShapeImpl();
				break;
				
			case ELLIPSE:
				graphic =new EllipseShapeImpl();
				break;
				
			case CROSS:
				graphic =new CrossShapeImpl();
				break;		
				
			case TRIANGLE:
				graphic =new TriangleShapeImpl();
				break;		
				
			case LABELS_LIST:
				graphic =new LabelsListShapeImpl();
				
				TextStyle textStyle =(TextStyle)BizObjectFactory.getInstance().get( BizObjects.TEXT_STYLE );				
				((LabelsListShape)graphic).setStyle( textStyle );
				break;
				
			case CDPOINT_CIRCLE:
				graphic =new CircleCDPointSymbolImpl();
				break;
				
			case CDPOINT_TRIANGLE:
				graphic =new TriangleCDPointSymbolImpl();
				break;			
				
			case CDPOINT_CROSS:
				graphic =new CrossCDPointSymbolImpl();
				break;	
				
			case CDPOINT_SQUARE:
				graphic =new SquareCDPointSymbolImpl();
				break;
				
			case CDPOINT_IMAGE:
				graphic =new ImageCDPointSymbolImpl();
				break;
				
			case BACKGROUND_IMAGE:
				graphic =new BackgroundImageShapeImpl();
				break;
				
			default:
				throw new TMapException( "Invalid graphic id: " + graphicId );
		}
		
		return graphic;

	}

}
